$(function(){
	var pl = $(".p:last");
	var reg = /(.*[\:\：]\s*)([\+\d\.]+)(\s*元)/g;
	//点击加号一次，增加商品数量1个
	
	$(".number_3").click(function(){

//		alert($(".number_2").val());
		/*var c = $(this).text();
		//alert(c);
		//定义变量
		var re=parseInt($(".number_2").val())+1;//取整，点一次加1
		//把变量赋给val
		$(".number_2").eq(c).val(re).siblings(".number_2").val();
		*/
		
		var me = $ (this), txt = me.prev (":text"), pc = me.closest(".p");
		    var val = parseFloat (txt.val ());
		    txt.val (val + 1);
		    var price = parseFloat (pc.prev(".p").text().replace(reg,'$2')) * txt.val ();
		    pc.next(".p").text (pc.next(".p").text().replace(reg, "$1" + price + "$3"));
		    var sum = 0;
		    $(".number_3").next(".p").each(function (i, dom)
		    {
		    	sum += parseFloat ($(this).text().replace(reg, "$2"));
		    });
		    pl.text(pl.text().replace(reg, "$1" + sum + "$3"));
	   
		
	});
	//减
	$(".number_1").click(function(){
		//alert(1);
		/*var me=$(this),txt=me.next(":text"), pc = me.closest(".p");
		var val = parseFloat(txt.val());
		val = val <= 1 ? 2 : val;
		txt.val(val-1);*/
		
		 var me = $ (this), txt = me.next (":text"), pc = me.closest("p");
		    var val = parseFloat (txt.val ());
		    val = val <= 1 ? 2 : val;
		    txt.val (val - 1);
		   /* var price = parseFloat (pc.prev("p").text().replace(reg,'$2')) * txt.val ();
		    pc.next("p").text (pc.next("p").text().replace(reg, "$1" + price + "$3"));
		    var sum = 0;
		    $(".p_num").next("p").each(function (i, dom)
		    {
		    	sum += parseFloat ($(this).text().replace(reg, "$2"));
		    });
		    pl.text(pl.text().replace(reg, "$1" + sum + "$3"));*/
		
	})
})
